<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
    <title>ShellCheck: SC1004 – This backslash+linefeed is literal. Break outside single quotes if you just want to break the line.</title>
    <link rel="stylesheet" href="css/bootstrap.min.css" />
  </head>
  <body style="margin-left: auto; margin-right: auto; max-width: 800px">
    <h1>SC1004 – ShellCheck Wiki</h1>
    <a href="https://github.com/koalaman/shellcheck/wiki/SC1004">See this page on GitHub</a>
    <p style="display: none"><a href="index.html">Sitemap</a></p>
    <hr />
    <h2
id="this-backslashlinefeed-is-literal-break-outside-single-quotes-if-you-just-want-to-break-the-line">This
backslash+linefeed is literal. Break outside single quotes if you just
want to break the line.</h2>
<p>(This warning was retired after v0.7.2 due to low signal-to-noise
ratio)</p>
<h3 id="problematic-code">Problematic code:</h3>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="SC1004.html#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="va">var</span><span class="op">=</span><span class="st">&#39;This is long \</span></span>
<span id="cb1-2"><a href="SC1004.html#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="st">piece of text&#39;</span></span></code></pre></div>
<h3 id="correct-code">Correct code:</h3>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="SC1004.html#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="va">var</span><span class="op">=</span><span class="st">&#39;This is a long &#39;</span><span class="dt">\</span></span>
<span id="cb2-2"><a href="SC1004.html#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="st">&#39;piece of text&#39;</span></span></code></pre></div>
<h3 id="rationale">Rationale:</h3>
<p>You have a single-quoted string containing a backslash followed by a
linefeed (newline). Unlike double-quotes or unquoted strings, this has
no special meaning. The string will contain a literal backslash and a
linefeed.</p>
<p>If you wanted to break the line but not add a linefeed to the string,
stop the single quote, break the line, and reopen it. This is
demonstrated in the correct code.</p>
<p>If you wanted to break the line and also include the linefeed as a
literal, you don't need a backslash:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="SC1004.html#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="va">var</span><span class="op">=</span><span class="st">&#39;This is a multi-line string</span></span>
<span id="cb3-2"><a href="SC1004.html#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="st">with an embedded linefeed&#39;</span></span></code></pre></div>
<h3 id="exceptions">Exceptions:</h3>
<p>If you do want a string containing a literal backslash+linefeed
combo, such as with <code>sed</code>, you can <a
href="ignore.html">ignore</a> this warning.</p>
    <hr />
    <p style='font-size: 80%'><a href="../index.html">ShellCheck</a> is a static analysis tool for shell scripts. This page is part of its documentation.</p>
  </body>
</html>


